import axios from "axios";

// '正常交货', '商家少货', '商家损货', '用户退货', '运输少货', '运输损货'
export const CheckResult = [
    {key: 1, label: '正常交货', value: '正常交货'},
    {key: 2, label: '商家少货', value: '商家少货'},
    {key: 3, label: '商家损货', value: '商家损货'},
    {key: 4, label: '用户退货', value: '用户退货'},
    {key: 5, label: '运输少货', value: '运输少货'},
    {key: 6, label: '运输损货', value: '运输损货'},
]

export const getOperatorsList = (callback) => {
    axios.get('/operator').then((response) => {
        callback(response.data);
    });
}

export const getOperator = (id, callback) => {
    axios.get('/operator/' + id).then((response) => {
        callback(response.data)
    })
}

export const deleteOperator = (id, callback) => {
    axios.delete('/operator/' + id).then((response) => {
        callback(response.data);
    });
}

export const updateOperator = (operatorData, callback) => {
    axios.put('/operator/' + operatorData.oid, operatorData).then((response) => {
        callback(response.data ? 1 : 0);
    })
}

export const createOperator = (operatorData, callback) => {
    axios.post('/operator', operatorData).then((response) => {
        callback(response.data ? 1 : 0)
    })
}

export const findIdByUsername = (username, callback) => {
    axios.get('/operator/id/' + username).then((response) => {
        callback(response.data);
    })
}

export const operatorCheckOut = (form, callback) => {
    axios.post('/operator/checkout', null, {params: form}).then((response) => {
        callback(response.data ? 1 : 0)
    })
}